###########################################################
# Herm libhermbase Makefile
# 2012-4-21
# HuangRuiGuang
# 
###########################################################
include ../common.mk

PRJ_NAME = base
OBJ_DIR = $(HERM_BUILD_DIR)/$(PRJ_NAME)

MODS = container network security socket utils socket/epoll
CXX_FILES = $(shell find $(MODS) -maxdepth 1 -name '*.cpp')
O_FILES = $(patsubst %.cpp, $(OBJ_DIR)/%.o, $(CXX_FILES))
#PROGRAM_SO = $(HERM_LIB_DIR)/libherm$(PRJ_NAME).so
PROGRAM_LIB = $(HERM_LIB_DIR)/libherm$(PRJ_NAME).a

#LDFLAGS = -shared

.PHONY: all clean
all: $(OBJ_DIR) $(PROGRAM_SO) $(PROGRAM_LIB)
	
#$(PROGRAM_SO): $(O_FILES) 
#	$(LD) $(LDFLAGS) $(LIBS) $^ -o $@ 

$(PROGRAM_LIB): $(O_FILES) 
	ar r $@ $^ 

$(OBJ_DIR)/%.o: %.cpp
	$(CXX) -o $@ $(CXXFLAGS) $^

$(OBJ_DIR):
	@echo $(OBJ_DIR)
	mkdir -p $@
	for val in $(MODS);do \
		mkdir -p $@/$${val}; \
	done;

clean:
	rm -rf $(OBJ_DIR)
#	rm -f $(PROGRAM_SO)
	rm -f $(PROGRAM_LIB)

rebuild: clean all
relink: all

